import React,{ Component } from 'react'
import { Modal,Input,Icon } from 'antd'
import { new_dir } from '../../../actions/disk'

class NewDirModal extends Component {
  constructor(props){
    super(props)
    this.state = {
      dir_name:''
    }
  }

  onChangeDirName = (e) => {
    this.setState({ dir_name: e.target.value });
  }

  onSumbit = () => {
    const { dispatch } = this.props
    dispatch(new_dir(dispatch,this.props.parent,this.state.dir_name))
    this.props.ok()
  }

  render(){
    return (
      <Modal
      title={'新建文件夹'}
      visible={this.props.visible}
      onOk={this.onSumbit}
      onCancel={this.props.cancel}
      width={350}
      >
      <Input
        placeholder="输入新目录名称"
        prefix={<Icon type="folder" />}
        value={this.state.dir_name}
        onChange={this.onChangeDirName}
      />
      </Modal>
    )
  }
}

export default NewDirModal
